package com.panomedic.core;

import com.panomedic.core.Photo;

/**
 *
 * @author Yare
 */
public class BoundaryHandler {

    public Photo active = null;
    public Photo initActive = null;
    public boolean alreadyChanged = false;

    public boolean aboveBnd = false;
    public boolean belowBnd = false;
    
    public Photo lastUsed = null;

    public Photo p1 = null;
    public Photo p2 = null;

    /**
     * Initialization of active photo attribute
     * @param p1
     * @param p2
     */
    public void init(Photo p1, Photo p2) {
        this.p1 = p1;
        this.p2 = p2;

        if (p1.getCenter().x <= p2.getCenter().x){
            initActive = p1;
        } else {
            initActive = p2;
        }
        active = initActive;
    }
    /**
     * Change active state from actual set photo to the other one
     */
    public void change() {
        if (active == p1)
            active = p2;
        else if (active == p2)
            active = p1;
    }

    public void clear() {
        active = initActive;
        alreadyChanged = false;
        aboveBnd = false;
        belowBnd = false;
    }

    public void setLastUsed(Photo lastUsed) {
        this.lastUsed = lastUsed;
    }

    @Override
    public String toString() {
        return active.toString();
    }

    
}
